home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / faq / amigafaq.lha / AmigaFAQ / programmer / stricmp.c < prev    next >
C/C++ Source or Header  |  1994-07-28  |  516b  |  35 lines

  1. #include <string.h>
  2. #include <ctype.h>
  3.  
  4. /*
  5.     Case insensitive strcmp
  6. */
  7. int stricmp(const char *_s1, const char *_s2)
  8.  
  9. { int c1, c2;
  10.  
  11.   do
  12.   { c1 = tolower((int) *_s1++);
  13.     c2 = tolower((int) *_s2++);
  14.   }
  15.   while(c1  &&  c1 == c2);
  16.   return(c1-c2);
  17. }
  18.  
  19. /*
  20.     Case insensitive strncmp
  21. */
  22. int strnicmp(const char *_s1, const char *_s2, size_t _n)
  23.  
  24. { int c1, c2;
  25.  
  26.   while(_n--)
  27.   { c1 = tolower((int) *_s1++);
  28.     c2 = tolower((int) *_s2++);
  29.     if (!c1  ||  c1 != c2)
  30.     { return(c1-c2);
  31.     }
  32.   }
  33.   return(0);
  34. }
  35.